/**
 * 天气预报插件
 */

(function(){
function weather(cityName,callback){
	if ('true' == API_AGENT_FLAG) {
		//代理服务器地址
		var agent=WEATHER_AGENT_URL+"baidu/getweather";
		//以下为实际地址
		var wUrl = encodeURIComponent("http://api.map.baidu.com/telematics/v3/weather?location="+cityName+"&output=json&ak=BotOjSIxOHZGQwVYqKX3LX7t&callback=?");
		
		//wUrl = wUrl.replace(/\&/g,'%26');
		
		wUrl = agent + "?agent=" + wUrl;
		$.getJSON(wUrl,function(data){
			callback && callback(data);
		});
		//document.write('<script type="text/javascript" src="' + wUrl + '"></script>');
	}else {
		var wUrl = "http://api.map.baidu.com/telematics/v3/weather?location="+cityName+"&output=json&ak=BotOjSIxOHZGQwVYqKX3LX7t&callback=?";
		
		$.getJSON(wUrl,function(data){
			callback && callback(data);
		});
	}
}
window.BWeather = window.BWeather || {};
BWeather.weather = weather;
})();

///**
// * 天气预报插件
// */
//srvMap.add('weatherAgent', '','front/sh/agent!defaultGet?uid=trendForecast');//天气代理
//
//(function(){
//function weather(cityName,callback){
//	var wUrl = "http://api.map.baidu.com/telematics/v3/weather?location="+cityName+"&output=json&ak=BotOjSIxOHZGQwVYqKX3LX7t&callback=?";
//	if ('true' == API_AGENT_FLAG) {
////		wUrl = escape(wUrl);
//		wUrl = wUrl.replace(/\&/g,'%26');
//		var par = "&url="+wUrl;
//		Util.ajax.postJsonSync(srvMap.get('weatherAgent'),par,function(json,status){
//			callback && callback(json);
//		});
//	}else {
//		$.getJSON(wUrl,function(data){
//			callback && callback(data);
//		});
//	}
//}
//window.BWeather = window.BWeather || {};
//BWeather.weather = weather;
//})();
